<template>
  <div class="line">
    <h2 class="txt">路线推荐</h2>
    <div class="content">
      <ul>
        <li v-for="item in lineList" :key="item.id" @click="getDetail">
          <div class="img">
            <img :src="item.picture" alt="" style="width: 275px; height: 185px; display: block;">
          </div>
          <div class="info">
            <div class="title">
              <p>{{item.title}}</p>
            </div>
            <div class="bottom">
              <div class="username">{{item.username}}</div>
              <div class="thumb">{{item.thumb}}人点赞</div>
            </div>
          </div>

        </li>
      </ul>
    </div>
    <br>
    <pagination></pagination>
    <el-divider></el-divider>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination.vue';
import { mapState } from "vuex";

export default {
  components: { Pagination },
  name: "MyLine",
  methods: {
    getDetail() {
      this.$router.push({
        name: "login",
      });
    },
  },
  mounted() {
    // 通知 vuex 发送请求，获取数据， 存储于仓库当中
    this.$store.dispatch("lineList");
  },
  computed: {
    ...mapState({
      // 当使用这个计算属性的时候，这个函数会执行一次， 函数的返回值即为计算属性的属性值
      lineList: (state) => {
        return state.line.lineList.records;
      },
    }),
  },
};
</script>

<style scoped>
.line {
  text-align: center;
}
.txt {
  /* text-align: center; */
  display: block;
  /* width: 100%; */
}

.info {
  padding: 18px;
  border: 1px;
  text-align: left;
}

.title {
  width: 237px;
  height: 48px;
  margin-top: 0px;
  font-size: 16px;
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Heiti SC", "WenQuanYi Micro Hei",
    sans-serif;
  overflow: hidden;
  line-height: 24px;
  text-align-last: left;
}

p {
  margin: 0;
  font-style: 24px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.username {
  width: 130.34px;
  height: 24px;
  margin-top: 16px;
  display: inline-block;
  font-size: 14px;
}

.thumb {
  height: 24px;
  margin-top: 16px;
  /* 行内块元素右靠 */
  float: right;
  font-size: 12px;
}

.img {
  width: 275px;
  height: 185px;
  display: block;
}

.title {
  display: block;
  text-align: center;
}

.content {
  display: flex;
}

ul {
  margin: auto;
  padding: 0;
  border: 0;
  text-align: center;
}

li {
  width: 275px;
  height: 300px;
  margin-left: 60px;
  margin-top: 20px;
  display: inline-block;
  /* vertical-align: top; */
  text-align: center;
  border: 1px solid #ececec;
}

li span {
  display: block;
}

li:nth-child(4n + 1) {
  margin-left: 0px;
}
</style>